package cerebrum.common;

import cerebrum.enums.SetUpMeaages;

import java.io.File;
import java.time.LocalDate;

public interface FilePathUtil {
    //获取今日图片路径
    public static String getImagesPath() {
        LocalDate newDate = LocalDate.now();
        //得到上面图片下载保存的地址
        return SetUpMeaages.imagesPath.getPath() + "\\" + newDate;
    }


    //获取昨日图片路径
    public static String getYesterDayImagesPath() {
        LocalDate newDate = LocalDate.now();
        LocalDate yesterDayDate = newDate.minusDays(1);
        //得到上面图片下载保存的地址
        return SetUpMeaages.imagesPath.getPath() + "\\" + yesterDayDate;
    }

    //获取今日图片路径
    public static String getToDayImagesPath() {
        LocalDate newDate = LocalDate.now();
        //得到上面图片下载保存的地址
        return SetUpMeaages.imagesPath.getPath() + "\\" + newDate;
    }

    public static String getDefaultImagesPath(){
       return SetUpMeaages.imagesPath.getPath() + File.separator + "default";
    }
    //获取昨日是否下载了图片
    public static boolean yesterDayImagesItExist(){
        String s = getYesterDayImagesPath();
        File file = new File(s);
        File[] files = file.listFiles();
        if (EmptyChecker.isEmpty(files)){
            return false;
        }
        return true;
    }
    //今天是否下载了图片
    public static boolean todayImagesItExist(){
        String s = getToDayImagesPath();
        File file = new File(s);
        File[] files = file.listFiles();
        if (EmptyChecker.isEmpty(files)){
            return false;
        }
        Integer downloadNum = Integer.valueOf(ConfigPropertiesUtil.get("downloadNum"));
        if (files.length<downloadNum){
            return false;
        }
        return true;
    }
}
